﻿@{
    ViewBag.Title = "Index";
}
<script type="text/javascript">
    $(function () {
        var data = new Date().toLocaleString();
        $("#input_date").attr("value", data);

        var ajaxbg = $("#background,#backup_loding");
        $("#backup_tip").hide();
        $("#restore_tip").hide();
        $("#delete_tip").hide();
        ajaxbg.hide();

        $("#backup").click(function () {
            $("#backup_tip").show();
            ajaxbg.show();
            $.post("/Utility/Backup", { backupname: $("#input_name").val() },
                function (data) {
                    var remark = $(".remark").val();
                    $("#backup_tip").hide();
                    $("#restore_tip").hide();
                    $("#delete_tip").hide();
                    ajaxbg.hide();
                    alert(data.Message);
                    $(".backup_table").append("<tr>" + "<td>" + data.Backupname + "</td>" + "<td>" + data.Time + "</td>"
                        + "<td>" + remark + "</td>" + '<td class="hide_file">' + data.File + "</td>"
                        + "<td>" + '<input type="button" value="还原" class="restore" />' + "</td>"
                        + "<td>" + '<input type="button" value="删除" class="delete" />' + "</td>"
                        + "</tr>");
                });
        });

        $("#backup_list .restore").live("click", function () {
            $("#restore_tip").show();
            ajaxbg.show();
            $.post("/Utility/Restore", { "file": $(this).parent().prev().text() },
                function (data) {
                    $("#backup_tip").hide();
                    $("#restore_tip").hide();
                    $("#delete_tip").hide();
                    ajaxbg.hide();
                    alert(data.Message);
                });
        });

        $("#backup_list .delete").live("click", function () {
            var $item = $(this).parent().parent();
            $("#delete_tip").show();
            ajaxbg.show();
            $.post("/Utility/Delete", { "file": $(this).parent().prev().prev().text() },
                function (data) {
                    $("#backup_tip").hide();
                    $("#restore_tip").hide();
                    $("#delete_tip").hide();
                    ajaxbg.hide();
                    alert(data.Message);
                    $item.remove();
                });
        });

        $.post("/Utility/GetBackupFileList", {}, function (data) {
            $.each(data, function () {
                $(".backup_table").append("<tr>" + "<td>" + this.Backupname + "</td>" + "<td>" + this.Time + "</td>"
                        + "<td>" + "修改内容，更新备份" + "</td>" + '<td class="hide_file">' + this.File + "</td>"
                        + "<td>" + '<input type="button" value="还原" class="restore" />' + "</td>"
                        + "<td>" + '<input type="button" value="删除" class="delete" />' + "</td>"
                        + "</tr>");
            });
        });
    });
</script>
<div class="mas">
    <div class="toptitle">
        系统管理员管理平台
    </div>
    <div class="mainbody">
        @Html.Partial("_PartviewAdmin")
        <div class="rightshow">
            <div class="wrap-right">
                <div class="classifyinfo">
                    <div class="system-location">
                        <a>管理系统</a>>><a>管理员管理</a>>><a>数据库备份</a>
                    </div>
                    <div class="system-Userinfo">
                        <span class="space">当前用户:</span><a>张测试</a> <span class="space">部门:</span><a>技术部</a>
                        <a class="space">退出</a>
                    </div>
                    <div class="clear">
                    </div>
                </div>
                <div class="main">
                    <div class="titlehead">
                        <img id="backup_title" alt="" src="../../Content/themes/picture/backup_title.png" />
                    </div>
                    <div class="work_area">
                        <div class="new_backup">
                            <div class="head_tip">
                                建立新的备份
                            </div>
                            <div class="backup_info">
                                <div class="leftinfo">
                                    <div class="backup_name">
                                        <span class="tip_label">备&nbsp;&nbsp;份&nbsp;&nbsp;名&nbsp;&nbsp ：</span>
                                        <input type="text" id="input_name" />
                                    </div>
                                    <div class="backup_date">
                                        <span class="tip_label">备 份 时 间：</span>
                                        <input type="text" id="input_date" readonly="readonly" value="" />
                                    </div>
                                    <div class="backup_manager">
                                        <span class="tip_label">备份管理员：</span>
                                        <input type="text" id="input_manager" readonly="readonly" value="张测试" />
                                    </div>
                                </div>
                                <div class="rightinfo">
                                    <div class="backup_remark">
                                        <span class="tip_label">备注信息：</span>
                                        <textarea class="remark" rows="" cols=""></textarea>
                                    </div>
                                    <div class="backup_btn">
                                        <input type="button" id="backup" title="开始备份" value="" />
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="clear">
                        </div>
                        <div class="backup_record">
                            <div class="head_tip">
                                历史备份记录
                            </div>
                            <div id="backup_list">
                                <table class="backup_table">
                                    <tr id="tr_head">
                                        <th id="th1">
                                            文件名
                                        </th>
                                        <th id="th2">
                                            备份时间
                                        </th>
                                        <th id="th3">
                                            备注信息
                                        </th>
                                        <th class="hide_file">
                                        </th>
                                        <th id="th4">
                                            还原
                                        </th>
                                        <th id="th5">
                                            删除
                                        </th>
                                    </tr>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div id="background" class="background" ></div> 
<div id="backup_loding" class="backup_loding">
    <div class="barbox">
        <div id="block_1" class="barlittle">
        </div>
        <div id="block_2" class="barlittle">
        </div>
        <div id="block_3" class="barlittle">
        </div>
        <div id="block_4" class="barlittle">
        </div>
        <div id="block_5" class="barlittle">
        </div>
    </div>
    <p id="backup_tip">
        数据备份中，请稍后…</p>
    <p id="restore_tip">
        数据还原中，请稍后…</p>
    <p id="delete_tip">
        数据删除中，请稍后…</p>
</div>
